Skip to content

Fix intword's decillion-to-googol gap and carry-over rounding - #364

Open
mmaxjr wants to merge 1 commit into
python-humanize:mainfrom
mmaxjr:fix/intword-decillion-googol-gap
Open

Fix intword's decillion-to-googol gap and carry-over rounding#364
mmaxjr wants to merge 1 commit into
python-humanize:mainfrom
mmaxjr:fix/intword-decillion-googol-gap

Conversation

@mmaxjr

@mmaxjr mmaxjr commented Jul 30, 2026

Copy link
Copy Markdown

Fixes #356

Problem

intword()'s powers table jumps straight from decillion (10**33) to googol (10**100), with no unit in between. Any value in [10**36, 10**100) got chopped into a decillion count that grows arbitrarily large:

>>> intword(10**50)
'100000000000000000.0 decillion'
>>> intword(10**100 - 10**93)
'9999999000000000610151082626636586748864734715312950532670947852288.0 decillion'

`powers` jumps from decillion (10**33) directly to googol (10**100),
so any value in [10**36, 10**100) was chopped into a decillion count
that grew arbitrarily large (e.g. 10**50 -> "100000000000000000.0
decillion"), and values that should round up into googol (e.g.
10**100 - 10**93) never carried over.

Only advance to the next named unit when the value actually rounds
up to it; otherwise there is no unit for that magnitude, so fall
back to the plain integer, mirroring how intword() already falls
back to a plain value below the smallest unit.

Fixes python-humanize#356

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@hugovk hugovk changed the title fix(intword): correct decillion-to-googol gap and carry-over rounding Fix intword's decillion-to-googol gap and carry-over rounding Aug 4, 2026
@hugovk hugovk added the changelog: Fixed For any bug fixes label Aug 4, 2026
@codecov

codecov Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.44%. Comparing base (42b4a1d) to head (c0d6e18).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #364      +/-   ##
==========================================
- Coverage   99.56%   95.44%   -4.12%     
==========================================
  Files          12       12              
  Lines         916      923       +7     
==========================================
- Hits          912      881      -31     
- Misses          4       42      +38     
Flag Coverage Δ
macos-latest ?
ubuntu-latest ?
windows-latest 95.44% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codspeed-hq

codspeed-hq Bot commented Aug 4, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 15 untouched benchmarks


Comparing mmaxjr:fix/intword-decillion-googol-gap (c0d6e18) with main (42b4a1d)

Open in CodSpeed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog: Fixed For any bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

intword: values between 10^36 and a googol format as huge decillion counts, and rounding to the next unit does not carry

2 participants